
package validator;

/**
 * Checks if a username is correct
 * @author Chris
 */
public class validUserName extends validator {
    public validUserName() { err = ERRORS.VALID; }
    
    public boolean isValid(String name) {
        if(name == null) {
            err = ERRORS.INVALID_USERNAME;
            return false;
        }
        //Allowed 1 or more characters, a - z or digits
        if(name.matches("([A-Z]|[a-z]|[0-9])+")) {
            err = ERRORS.VALID;
            return true;
        }
        err = ERRORS.INVALID_USERNAME;
        return false;
    }
}
